package JUC.创建线程.资源共享;

public class ShareSourceByThread {
    public static void main(String[] args) {
        Station station = new Station();
        station.setName("窗口1");
        Station station2 = new Station();
        station2.setName("窗口2");

        station.start();
        station2.start();
    }
}

class Station extends Thread {
    int ticket = 5;

    @Override
    public void run() {
        while (ticket > 0) {
            System.out.println(Thread.currentThread().getName() + "卖出第 " + (5 - ticket) + "张票");
            ticket--;
        }
    }
}
